﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="房产销冠, 房地产,卡考网络" />
    <meta name="description" content="上海卡考网络有限公司" />
    <title>房产销冠</title>
    <link rel="stylesheet" href="css/global.css" type="text/css" />
    <link rel="stylesheet" href="css/form.css" type="text/css" />
    <link rel="stylesheet" href="css/default.css" />
    <link href="bootstrap/iCheck-master/skins/minimal/orange.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="css/gri.controls.css" type="text/css" />
    <link rel="stylesheet" href="css/bootstrap-switch.css" type="text/css" />
    <script src="http://dn-blqw.qbox.me/jq+bs+art.js" type="text/javascript"></script>
    <script src="js/jquery-form.js" type="text/javascript"></script>
    <script src="js/underscore.js" type="text/javascript"></script>
    <script src="js/jquery-my-Extension.js" type="text/javascript"></script>
    <script src="js/kk.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/WdatePicker.js"></script>
    <!--<script type="text/javascript" src="js/dateRange.js"></script>-->
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/formValidator.js"></script>
    <!--图片上传-->
    <link href="Scripts/webuploader/webuploader.css" rel="stylesheet" />
    <script type="text/javascript" src="bootstrap/iCheck-master/icheck.js"></script>
    <script type="text/javascript" src="js/bootstrap-switch.min.js"></script>
    <script src="Scripts/webuploader/webuploader.min.js" type="text/javascript"></script>
    <script src="Scripts/webuploader/webupload.expand.js" type="text/javascript"></script>
    <script type="text/javascript">
    </script>
    <!--<script charset="utf-8" src="js/kindeditor-min.js"></script>-->
    <!--<script charset="utf-8" src="js/zh_CN.js"></script>-->
    <script type="text/javascript">

    </script>
</head>
<body style="background: #f1f1f1;">
    <div class="main01 pb50">
        <div class="fromtit1 clearfix">
            <h1 class="ff">权限管理</h1>
            <a href="#" class="gouback" onclick="f_Back();">返回</a>
        </div>
        <div class="fromtit2 clearfix">
            <h2 class="ff">权限编辑</h2>
        </div>
        <div class="frommod clearfix">
            <form id="form1">
                <input type="hidden" id="kid" name="kid" value="0" />
                <input type="hidden" id="ruleKid" name="ruleKid" value="0" />
                <table border="0" cellspacing="0" cellpadding="0" class="fromtab1">
                    <tr>
                        <th>用户名：&nbsp;</th>
                        <td>
                            <input type="text" id="F_LoginName" name="F_LoginName" value="" class="inpall inp435" placeholder="请填写需要开通的用户名" maxlength="255" />
                        </td>
                    </tr>
                    <tr>
                        <th>开通城市：&nbsp;</th>
                        <td>
                            <select id="F_CityKid" name="F_CityKid" class="selall sel100 fl" style="margin-right: 11px;">
                                <option value="-1">请选择</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>权限级别：&nbsp;</th>
                        <td>
                            <input type="text" id="F_AuthorityID" name="F_AuthorityID" value="" class="inpall inp435" readonly="readonly" />
                            <input type="hidden" id="F_AuthorityID_hidden" name="F_AuthorityID" value="" />
                        </td>
                    </tr>
                    <tr>
                        <th>是否为供应商：&nbsp;</th>
                        <td style="width: 120px;">
                            <label><input type="radio" name="F_IsProvider" value="0" checked="checked" />非供应商</label>
                            <label style="margin-left:20px;"><input id="F_IsProvider" type="radio" name="F_IsProvider" value="1" />供应商</label>
                        </td>
                    </tr>
                    <tr>
                        <th>权限开关：&nbsp;</th>
                        <td style="width: 120px;">
                            <label><input type="radio" name="F_IsOpen" value="1" checked="checked" />开启</label>
                            <label style="margin-left:20px;"><input id="F_IsOpen" type="radio" name="F_IsOpen" value="0" />关闭</label>
                        </td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <div class="sinput">
                                <input type="button" class="Save" value="保存" onclick="f_Save()" />
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

    <script type="text/javascript">
        var kid = "";
        $(function () {
            f_GetCityList();
            bindAuthID();
            kid = GetUrlParam("kid");
            var loginName = GetUrlParam("loginName");
            var cityKid = GetUrlParam("cityKid");
            var isOpen = GetUrlParam("isOpen");
            var authorityID = GetUrlParam("authorityID");
            if (kid > 0) {
                if (loginName != "") {
                    $("#F_LoginName").val(loginName);
                }
                if (cityKid != "") {
                    $("#F_CityKid option").each(function () {
                        var val = $(this).val();
                        if (val == cityKid) {
                            $(this).attr('selected', true);
                            if (cityKid == 0) {
                                $("#F_AuthorityID").val('全国管理');
                                $("#F_AuthorityID_hidden").val(1);
                            } else if (cityKid > 0) {
                                $("#F_AuthorityID").val('城市管理');
                                $("#F_AuthorityID_hidden").val(3);
                            } else {
                                $("#F_AuthorityID").val("");
                                $("#F_AuthorityID_hidden").val("");
                            }
                        }
                    })
                }
                if (isOpen != "") {
                    if (isOpen == 0) {
                        $("#F_IsOpen").attr("checked", true);
                    }
                }
                if (authorityID == 999) {
                    $("#F_AuthorityID_hidden").val(999);
                }
            }
        });


        function bindAuthID() {
            $("#F_CityKid").change(function () {
                var vl = $(this).val();
                if (vl == 0) {
                    $("#F_AuthorityID").val('全国管理');
                    $("#F_AuthorityID_hidden").val(1);
                } else if (vl > 0) {
                    $("#F_AuthorityID").val('城市管理');
                    $("#F_AuthorityID_hidden").val(3);
                } else {
                    $("#F_AuthorityID").val("");
                    $("#F_AuthorityID_hidden").val("");
                }
            });
        }

        function f_GetCityList() {
            var data = kk.api.get("/PointStoreAuth/Auth_GetAuthCityList", function (data) {
                $("#F_CityKid").empty();
                $.each(data, function (i, obj) {
                    $("#F_CityKid").append("<option value='" + obj.F_CityKid + "'>" + obj.F_CityName + "</option>");
                });
            });
        }

        function f_Back() {
            self.location = document.referrer;
        }

        function f_Save() {
            if ($("#F_LoginName").val() == "") {
                $kk.popup("用户名必填", "danger", 1000);
                return;
            }
            if ($("#F_CityKid option:checked").val() == -1) {
                $kk.popup("必须选择一个城市", "danger", 1000);
                return;
            }
            var F_IsProvider = $("input[name='F_IsProvider']:checked").val();

            var data = {
                F_LoginName: $("#F_LoginName").val(),
                F_AuthorityID: F_IsProvider == 1 ? 999 : $("#F_AuthorityID_hidden").val(),
                F_CityKid: $("#F_CityKid option:checked").val(),
                F_CityName: $("#F_CityKid option:checked").text(),
                F_IsOpen: $("input[name='F_IsOpen']:checked").val()
            }

            var url = "/PointStoreAuth/Auth_AddUser";
            if (kid > 0) {
                url = "/PointStoreAuth/Auth_EditUser";
            }
            kk.api.post(url, data, function (res) {
                if (res) {
                    $kk.popup("操作成功", "success", 1000);
                } else {
                    $kk.popup("操作失败", "danger", 1000);
                }
            });
        }
    </script>
</body>
</html>
